package com.atguigu.doc;

import org.apache.http.HttpHost;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * create by undeRdoG on  2021-06-21  21:21
 * 凡心所向，素履以往，生如逆旅，一苇以航。
 */
public class ESTest_Doc_Delete_Batch {

    public static void main(String[] args) throws IOException {
        //  创建ES 客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200))
        );


        // 批量删除
        BulkRequest request = new BulkRequest();

        request.add(new DeleteRequest().index("user").id("1001"));
        request.add(new DeleteRequest().index("user").id("1002"));


        esClient.bulk(request, RequestOptions.DEFAULT);

    }
}
